
//import com.sun.org.apache.bcel.internal.generic.AALOAD;
import com.toedter.calendar.JDateChooser;
import java.awt.Color;
import java.util.Enumeration;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.filechooser.FileFilter;
import javax.swing.tree.DefaultTreeModel;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

//import org.jdesktop.swingx.calendar.*;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Tomasz
 */
public class MyJApplet extends javax.swing.JApplet {

    String global_pattern = "";
    int plan_count = 1;
    String data = "Data";

    /**
     * Initializes the applet MyJApplet
     */
    @Override
    public void init() {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MyJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MyJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MyJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MyJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        this.setSize(1000, 900);
 //       jLabel5.setVisible(false);
        /* Create and display the applet */
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    initComponents();
                    jTree1.setEditable(true);
                    new MessageBox("Pamiętaj o potwierdzaniu danych enterem.").show();
                    DefaultMutableTreeNode r = (DefaultMutableTreeNode) jTree1.getModel().getRoot();
                    r.setUserObject("Opis scenariusza");
refresh_tree();
                    jTextField2.setToolTipText("Nazwa sytuacji");
                    jTextField5.setToolTipText("Typ funkcji autora");
                    jTextField10.setToolTipText("Nazwa identyfikująca autora");
                    jTextField4.setToolTipText("Specyfikacja danych zespołu");
                    jTextField1.setToolTipText("Cel główny planu");
                    jTextArea1.setToolTipText("Część swobodna opisu");
                    jDateChooser1.setToolTipText("Data");
                    jDateChooser1.setDate(new Date());
                    Date temp = new Date();
                    int day = temp.getDate();
                    temp.setDate((day+1)%31);
                    jDateChooser2.setDate(temp);
                   
                    //INICJALIZACJA DAT
                    
    /*              searchNode_and_Replace(jDateChooser1.getToolTipText(),"Data: " + jDateChooser1.getDate().toGMTString() );
        jDateChooser1.setToolTipText( "Data: " + jDateChooser1.getDate().toGMTString());
        
        Date date1 = jDateChooser1.getDate();
        date1.setHours( jComboBox3.getSelectedIndex());
        date1.setMinutes(jComboBox4.getSelectedIndex());
        jDateChooser1.setDate(date1);
        
        Date date2 = jDateChooser2.getDate();
        date2.setHours( jComboBox5.getSelectedIndex());
        date2.setMinutes( jComboBox6.getSelectedIndex());
        jDateChooser2.setDate(date2);
        
         if (jDateChooser1.getDate() == jDateChooser2.getDate())
                 {
                 searchNode_and_Replace(data, "Data: " + jDateChooser2.getDate());
                            data = "Data: " + jDateChooser2.getDate();
                        }
                        else 
                        {
                           
                           if (jDateChooser2.getDate().before(jDateChooser1.getDate())) return;
                           searchNode_and_Replace(data, "Data: " + jDateChooser1.getDate() +" - " + jDateChooser2.getDate());
                            data = "Data: " + jDateChooser1.getDate() +" - " + jDateChooser2.getDate();
                            
                        }*/
                    
                    //=======================================================================================
                    
                    jDateChooser1.getDateEditor().addPropertyChangeListener(
                            new PropertyChangeListener() {
                        @Override
                        public void propertyChange(PropertyChangeEvent evt) {

                    /*    if (jDateChooser2.getDate() == null || (jDateChooser1.getDate().getDay() == jDateChooser2.getDate().getDay() &&  jDateChooser1.getDate().getMonth() == jDateChooser2.getDate().getMonth() && jDateChooser1.getDate().getYear() == jDateChooser2.getDate().getYear() ))
                        {
                       { 
                           try{
                               searchNode_and_Replace(data, "Data: " + jDateChooser1.getDate().toString());
                           }
                           catch (Exception e )
                           {
                               
                           }
                            data = "Data: " + jDateChooser1.getDate().toString();
                        }
                        }*/
                            jButton8.setForeground(Color.red);
                    }}
                            );
                    
               
                         jDateChooser2.getDateEditor().addPropertyChangeListener(
                            new PropertyChangeListener() {

                        @Override
                        public void propertyChange(PropertyChangeEvent evt) {
                      /*  if (jDateChooser1.getDate() == null || (jDateChooser1.getDate().getDay() == jDateChooser2.getDate().getDay() &&  jDateChooser1.getDate().getMonth() == jDateChooser2.getDate().getMonth() && jDateChooser1.getDate().getYear() == jDateChooser2.getDate().getYear() )){
                            searchNode_and_Replace(data, "Data: " + jDateChooser2.getDate());
                            data = "Data: " + jDateChooser2.getDate();
                        }
                        else 
                        {
                           
                           if (jDateChooser2.getDate().before(jDateChooser1.getDate())) return;
                           searchNode_and_Replace(data, "Data: " + jDateChooser1.getDate() +" - " + jDateChooser2.getDate());
                            data = "Data: " + jDateChooser1.getDate() +" - " + jDateChooser2.getDate();
                            
                        }*/
                             jButton8.setForeground(Color.red);
                        }
                    }
                            );

                    jComboBox3.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                         jButton8.setForeground(Color.red);
                        }
                    });
                    
                                jComboBox4.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                         jButton8.setForeground(Color.red);
                        }
                    });
                                
                                      jComboBox5.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                         jButton8.setForeground(Color.red);
                        }
                    });  
                                                          jComboBox6.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                         jButton8.setForeground(Color.red);
                        }
                    });
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void refresh_tree() {

        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        model.reload();
    }

    /**
     * This method is called from within the init() method to initialize the
     * form. WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jTextField2 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jTextField62 = new javax.swing.JTextField();
        jLabel69 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTree1 = new javax.swing.JTree();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextArea3 = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        jTextField5 = new javax.swing.JTextField();
        jTextField10 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jButton6 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jDateChooser1 = new com.toedter.calendar.JDateChooser();
        jDateChooser2 = new com.toedter.calendar.JDateChooser();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jComboBox3 = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        jComboBox4 = new javax.swing.JComboBox();
        jComboBox5 = new javax.swing.JComboBox();
        jLabel19 = new javax.swing.JLabel();
        jComboBox6 = new javax.swing.JComboBox();
        jButton8 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jButton34 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jTextField3 = new javax.swing.JTextField();
        jTextField59 = new javax.swing.JTextField();
        jTextField60 = new javax.swing.JTextField();
        jTextField61 = new javax.swing.JTextField();
        jButton35 = new javax.swing.JButton();
        jButton36 = new javax.swing.JButton();
        jLabel17 = new javax.swing.JLabel();
        jLabel66 = new javax.swing.JLabel();
        jLabel67 = new javax.swing.JLabel();
        jLabel68 = new javax.swing.JLabel();
        jButton37 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel18 = new javax.swing.JLabel();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();

        setPreferredSize(new java.awt.Dimension(1000, 900));
        setStub(null);

        jLabel1.setText("Nazwa sytuacji:");

        jLabel5.setText("Dane zespołu:");

        jLabel10.setText("Część swobodna opisu:");

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jTextArea1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                textAreaKeyTyped(evt);
            }
        });
        jScrollPane1.setViewportView(jTextArea1);

        jTextField2.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                odkolorowanie(evt);
            }
        });
        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt);
            }
        });

        jTextField4.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                jTextField4CaretUpdate(evt);
            }
        });
        jTextField4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField4ActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Plan sytuacji:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(0, 0, 0)));

        jLabel8.setText("Opis zdarzenia:");

        jLabel9.setText("Opis stanu:");

        jLabel6.setText("Specyfikacja zadania");

        jLabel7.setText("Opis aktywności:");

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/plus-icon (1).png"))); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/plus-icon (1).png"))); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/plus-icon (1).png"))); // NOI18N
        jButton3.setToolTipText("");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/plus-icon (1).png"))); // NOI18N
        jButton4.setToolTipText("");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/plus-icon (1).png"))); // NOI18N
        jButton5.setToolTipText("");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jLabel14.setText("Plan nr:");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1" }));

        jTextField62.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                jTextField62CaretUpdate(evt);
            }
        });
        jTextField62.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField62ActionPerformed(evt);
            }
        });

        jLabel69.setText("Nazwa");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel9)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addGap(2, 2, 2))
                            .addComponent(jLabel6)
                            .addComponent(jLabel8)
                            .addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(48, 48, 48)
                        .addComponent(jLabel69)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField62, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(114, 114, 114))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel14)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButton5, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField62, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel69))
                .addGap(8, 8, 8)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jButton1))
                .addGap(12, 12, 12)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel7)
                    .addComponent(jButton2))
                .addGap(22, 22, 22)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel8)
                    .addComponent(jButton3))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9)
                    .addComponent(jButton4))
                .addContainerGap())
        );

        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root");
        javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Część ustrukturalizowana opisu");
        javax.swing.tree.DefaultMutableTreeNode treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Nazwa sytuacji");
        treeNode2.add(treeNode3);
        treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Specyfikajcja danych autora scenariusza");
        javax.swing.tree.DefaultMutableTreeNode treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Typ funkcji autora");
        treeNode3.add(treeNode4);
        treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Nazwa identyfikująca autora");
        treeNode3.add(treeNode4);
        treeNode2.add(treeNode3);
        treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Specyfikacja danych zespołu");
        treeNode2.add(treeNode3);
        treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Data");
        treeNode2.add(treeNode3);
        treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Cel główny planu");
        treeNode2.add(treeNode3);
        treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Plan reprezentujący deskrypcję sytuacji");
        treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Nazwa planu");
        treeNode3.add(treeNode4);
        treeNode2.add(treeNode3);
        treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Typ Bazowy");
        treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Nazwa");
        treeNode3.add(treeNode4);
        treeNode2.add(treeNode3);
        treeNode1.add(treeNode2);
        treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Część swobodna opisu");
        treeNode1.add(treeNode2);
        jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
        jTree1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jtree1_propertyChange(evt);
            }
        });
        jScrollPane3.setViewportView(jTree1);

        jLabel12.setText("Podgląd drzewa XML:");

        jLabel13.setText("Podgląd pliku wynikowego:");

        jTextArea3.setColumns(20);
        jTextArea3.setRows(5);
        jScrollPane4.setViewportView(jTextArea3);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Specyfikacja danych autora scenariusza"));

        jTextField5.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                jTextField5CaretUpdate(evt);
            }
        });
        jTextField5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField5ActionPerformed(evt);
            }
        });

        jTextField10.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                jTextField10CaretUpdate(evt);
            }
        });
        jTextField10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField10ActionPerformed(evt);
            }
        });

        jLabel4.setText("Typ Funkcji");

        jLabel11.setText("ID autora");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel11))
                .addGap(61, 61, 61)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, 265, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 265, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel4))
                    .addComponent(jTextField5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton6.setText("Zapisz...");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Data"));

        jDateChooser1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                zmien_date(evt);
            }
        });

        jLabel2.setText("od:");

        jLabel3.setText("do:");

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));

        jLabel15.setText(":");

        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59" }));

        jComboBox5.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));

        jLabel19.setText(":");

        jComboBox6.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59" }));

        jButton8.setText("OK");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jDateChooser1, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                    .addComponent(jDateChooser2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jComboBox6, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(47, 47, 47)
                        .addComponent(jButton8)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jDateChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel15)
                        .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jDateChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addContainerGap())
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel19)
                            .addComponent(jComboBox6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton8))))
        );

        jButton7.setText("Gereruj szablon");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton9.setText("Usuń");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jTextField1.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                jTextField1CaretUpdate(evt);
            }
        });
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                glowny_cel(evt);
            }
        });

        jLabel16.setText("Cel główny planu");

        jButton34.setIcon(new javax.swing.ImageIcon(getClass().getResource("/plus-icon (1).png"))); // NOI18N
        jButton34.setToolTipText("");
        jButton34.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton34ActionPerformed(evt);
            }
        });

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Typ Bytu Bazowego Ustanawiajacego Sytuację"));

        jTextField3.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                jTextField3CaretUpdate(evt);
            }
        });
        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });

        jButton35.setIcon(new javax.swing.ImageIcon(getClass().getResource("/plus-icon (1).png"))); // NOI18N
        jButton35.setToolTipText("");
        jButton35.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton35ActionPerformed(evt);
            }
        });

        jButton36.setIcon(new javax.swing.ImageIcon(getClass().getResource("/plus-icon (1).png"))); // NOI18N
        jButton36.setToolTipText("");
        jButton36.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton36ActionPerformed(evt);
            }
        });

        jLabel17.setText("Nazwa Bytu Bazowego");

        jLabel66.setText("Jest Klasyfikowany Przez");

        jLabel67.setText("Jest Podtypem");

        jLabel68.setText("Ma Podtyp");

        jButton37.setIcon(new javax.swing.ImageIcon(getClass().getResource("/plus-icon (1).png"))); // NOI18N
        jButton37.setToolTipText("");
        jButton37.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton37ActionPerformed(evt);
            }
        });

        jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/plus-icon (1).png"))); // NOI18N
        jButton10.setToolTipText("");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1" }));

        jLabel18.setText("Typ Bazowy nr:");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel17)
                            .addComponent(jLabel66)
                            .addComponent(jLabel67)
                            .addComponent(jLabel68))
                        .addGap(25, 25, 25)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jTextField61, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton36, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jTextField60, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton35, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jTextField59, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton37, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel18)
                        .addGap(63, 63, 63)
                        .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel18)
                        .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButton10, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField59, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel66))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTextField60, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel67))
                            .addComponent(jButton35))
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGap(8, 8, 8)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField61, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton36)))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel68))))
                    .addComponent(jButton37))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton11.setText("Odśwież");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jButton12.setText("jButton12");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton6)
                        .addGap(18, 18, 18))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel13)
                                    .addComponent(jLabel10))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE)
                                    .addComponent(jScrollPane4)))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(38, 38, 38)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel16))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(106, 106, 106)
                                        .addComponent(jButton12))
                                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 376, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 338, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(jButton34, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 407, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(49, 49, 49)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(jButton12)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton34, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel16)))
                        .addGap(18, 18, 18)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane3)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton9)
                    .addComponent(jButton7)
                    .addComponent(jButton6)
                    .addComponent(jButton11))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed
        // TODO add your handling code here:
        String s = jTextField4.getText();


        searchNode_and_Replace(jTextField4.getToolTipText(), "Specyfikacja danych zespołu : " + s);
        jTextField4.setToolTipText("Specyfikacja danych zespołu : " + s);

jTextField4.setForeground(Color.decode("#8fc400"));

    }//GEN-LAST:event_jTextField4ActionPerformed
List rola_w_planie;
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        // TODO add your handling code here:

         final JFrame f = new JFrame() ;
    
  //  Container content = f.getContentPane();
    final JPanel content = new JPanel(); 
    JScrollPane jsp = new JScrollPane(content);
    f.add(jsp);
    rola_w_planie = new ArrayList();
    content.setBackground(Color.white);
    content.setBackground(Color.white);
    content.setLayout(new GridLayout(0,3));
    List pm = new ArrayList();
    pm.add("nazwaRoliAgentywnej");
    pm.add("nazwaRoliPacjensa-Obiektu");
    pm.add("nazwaRoliPacjensa-Beneficjenta");
    pm.add("nazwaRoliInstrumentalnej");
    pm.add("nazwaRoliSposobuWykonania");
    pm.add("nazwaRoliWynikowej");
    pm.add("nazwaRoliLokalizujacejWPrzestrzeni");
    pm.add("nazwaRoliReifikujacej");
    pm.add("nazwaRoliPrzedmiotowej");
    pm.add("nazwaRoliPodmiotowej");
 
    final JLabel l1 = new JLabel("Nazwa zadania:");
    final JLabel l2 = new JLabel("Rola w planie:");
    final JLabel l3 = new JLabel("Typ Roli:");
    final JLabel l4 = new JLabel("Klasyfikuje");
    final JComboBox cb = new JComboBox(pm.toArray());
    final JTextField klas = new JTextField();
    final JTextField tf = new JTextField();
    final JTextField tf2 = new JTextField();
    final JButton gap = new JButton();
    final JButton add = new JButton(jButton34.getIcon());
    final ActionListener l = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                 rola_w_planie.add(tf2.getText()+", klasyfikuje: " + klas.getText());
              tf2.setText("");
              klas.setText("");
                 add.setEnabled(false);
              f.validate();
f.repaint();
            }
        };

     final JButton ok = new JButton("OK");
     add.setEnabled(false);
     klas.addActionListener(new ActionListener() {

             @Override
             public void actionPerformed(ActionEvent e) {
                 add.setEnabled(true);
             }
         });
    cb.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                  ActionListener al = null;
            if (cb.getSelectedItem().toString().equals("nazwaRoliWynikowej"))
            {

                    content.remove(l2);
                    content.remove(tf2);
                    content.remove(add);
                    add.removeActionListener(l);
                    content.remove(l4);
                    content.remove(klas);
                    List items = new ArrayList();
                    items.add("nazwaRoli-SkutkuRozpoczynanego");
                    items.add("nazwaRoli-SkutkuKonczonego");
                    final JComboBox jc = new JComboBox(items.toArray());
                    content.add(jc);
                    content.add(tf2);
                    content.add(add);
                  
                    al = new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                                rola_w_planie.add(tf2.getText()+" typu "+jc.getSelectedItem().toString()+", klasyfikuje: " + klas.getText());
              tf2.setText("");
              klas.setText("");
              add.setEnabled(false);
              f.validate();
f.repaint();
              
                    }
                };
                    add.addActionListener(al);
                    content.add(l4);
                    content.add(klas);
                    
                    
                    
                    f.invalidate();
f.validate();
f.repaint();
            }
            else
            {
                content.removeAll();
                try{
                add.removeActionListener(al);
                }
                catch (Exception exc){}
                add.addActionListener(l);
                
                    content.add(l1);
    content.add(tf);
    content.add(ok);
    content.add(l3);
    content.add(cb);    
    content.add(gap);
    content.add(l2);
    content.add(tf2);
    content.add(add);
    content.add(l4);
    content.add(klas);
                
                
            }
            }
        });
    
    
   
     
    gap.setVisible(false);

    add.addActionListener(l);
    
   
    
    ok.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               
                DefaultMutableTreeNode zd = new DefaultMutableTreeNode("Specyfikacja zadnia");
                DefaultMutableTreeNode nazwa = new DefaultMutableTreeNode("Nazwa Zadania: "+tf.getText() );
                zd.add(nazwa);
                for (int i = 0;i<rola_w_planie.size();i++)
                {
                    DefaultMutableTreeNode rola;
                          rola  = new DefaultMutableTreeNode(cb.getSelectedItem().toString() +  ": "+ rola_w_planie.get(i));
                          zd.add(rola);
                }
                 if (jComboBox1.getSelectedIndex() ==0) {
            searchNode_and_add_child("Plan reprezentujący deskrypcję sytuacji", zd);
        } else {
            searchNode_and_add_child("Plan reprezentujący deskrypcję sytuacji "+ (jComboBox1.getSelectedIndex()+1),zd);
        }
                 f.hide();
            }
        });
  
    content.add(l1);
    content.add(tf);
    content.add(ok);
    content.add(l3);
    content.add(cb);    
    content.add(gap);
    content.add(l2);
    content.add(tf2);
    content.add(add);
    content.add(l4);
    content.add(klas);

    f.setSize(800, 200);
    f.show();
   

    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    
    
     
        // TODO add your handling code here:

         final JFrame f = new JFrame() ;
    
  //  Container content = f.getContentPane();
    final JPanel content = new JPanel(); 
    JScrollPane jsp = new JScrollPane(content);
    f.add(jsp);
    rola_w_planie = new ArrayList();
    content.setBackground(Color.white);
    content.setBackground(Color.white);
    content.setLayout(new GridLayout(0,3));
    List pm = new ArrayList();
    pm.add("nazwaRoliAgentywnej");
    pm.add("nazwaRoliPacjensa-Obiektu");
    pm.add("nazwaRoliPacjensa-Beneficjenta");
    pm.add("nazwaRoliInstrumentalnej");
    pm.add("nazwaRoliSposobuWykonania");
    pm.add("nazwaRoliWynikowej");
    pm.add("nazwaRoliLokalizujacejWPrzestrzeni");
    pm.add("nazwaRoliReifikujacej");
    pm.add("nazwaRoliPrzedmiotowej");
    pm.add("nazwaRoliPodmiotowej");
 
    final JLabel l1 = new JLabel("Nazwa zdarzenia:");
    final JLabel l2 = new JLabel("Rola w planie:");
    final JLabel l3 = new JLabel("Typ Roli:");
    final JLabel l4 = new JLabel("Klasyfikuje");
    final JComboBox cb = new JComboBox(pm.toArray());
    final JTextField klas = new JTextField();
    final JTextField tf = new JTextField();
    final JTextField tf2 = new JTextField();
    final JButton gap = new JButton();
   final JButton add = new JButton(jButton34.getIcon());
    final ActionListener l = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                 rola_w_planie.add(tf2.getText()+", klasyfikuje: " + klas.getText());
              tf2.setText("");
              klas.setText("");
               add.setEnabled(false);
              f.validate();
f.repaint();
            }
        };
    
         klas.addActionListener(new ActionListener() {

             @Override
             public void actionPerformed(ActionEvent e) {
                 add.setEnabled(true);
             }
         });
 
     final JButton ok = new JButton("OK");
    cb.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                  ActionListener al = null;
            if (cb.getSelectedItem().toString().equals("nazwaRoliWynikowej"))
            {

                    content.remove(l2);
                    content.remove(tf2);
                    content.remove(add);
                    add.removeActionListener(l);
                    content.remove(l4);
                    content.remove(klas);
                    List items = new ArrayList();
                    items.add("nazwaRoli-SkutkuRozpoczynanego");
                    items.add("nazwaRoli-SkutkuKonczonego");
                    final JComboBox jc = new JComboBox(items.toArray());
                    content.add(jc);
                    content.add(tf2);
                    content.add(add);
                  
                    al = new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                                rola_w_planie.add(tf2.getText()+" typu "+jc.getSelectedItem().toString()+", klasyfikuje: " + klas.getText());
              tf2.setText("");
              klas.setText("");
               add.setEnabled(false);
              f.validate();
f.repaint();
                    }
                };
                    add.addActionListener(al);
                    content.add(l4);
                    content.add(klas);
                    
                    
                    
                    f.invalidate();
f.validate();
f.repaint();
            }
            else
            {
                content.removeAll();
                try{
                add.removeActionListener(al);
                }
                catch (Exception exc){}
                add.addActionListener(l);
                
                    content.add(l1);
    content.add(tf);
    content.add(ok);
    content.add(l3);
    content.add(cb);    
    content.add(gap);
    content.add(l2);
    content.add(tf2);
    content.add(add);
    content.add(l4);
    content.add(klas);
                
                
            }
            }
        });
    
    
   
     
    gap.setVisible(false);

    add.addActionListener(l);
    
   
    
    ok.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               
                DefaultMutableTreeNode zd = new DefaultMutableTreeNode("Specyfikacja opisu");
                DefaultMutableTreeNode nazwa = new DefaultMutableTreeNode("Nazwa opisu: "+tf.getText() );
                zd.add(nazwa);
                for (int i = 0;i<rola_w_planie.size();i++)
                {
                    DefaultMutableTreeNode rola;
                          rola  = new DefaultMutableTreeNode(cb.getSelectedItem().toString() +  ": "+ rola_w_planie.get(i));
                          zd.add(rola);
                }
                 if (jComboBox1.getSelectedIndex() ==0) {
            searchNode_and_add_child("Plan reprezentujący deskrypcję sytuacji", zd);
        } else {
            searchNode_and_add_child("Plan reprezentujący deskrypcję sytuacji "+ (jComboBox1.getSelectedIndex()+1),zd);
        }
                 f.hide();
            }
        });
  
    content.add(l1);
    content.add(tf);
    content.add(ok);
    content.add(l3);
    content.add(cb);    
    content.add(gap);
    content.add(l2);
    content.add(tf2);
    content.add(add);
    content.add(l4);
    content.add(klas);

    f.setSize(800, 200);
    f.show();
   
   

 

        
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  
        // TODO add your handling code here:

         final JFrame f = new JFrame() ;
    
  //  Container content = f.getContentPane();
    final JPanel content = new JPanel(); 
    JScrollPane jsp = new JScrollPane(content);
    f.add(jsp);
    rola_w_planie = new ArrayList();
    content.setBackground(Color.white);
    content.setBackground(Color.white);
    content.setLayout(new GridLayout(0,3));
    List pm = new ArrayList();
    pm.add("nazwaRoliAgentywnej");
    pm.add("nazwaRoliPacjensa-Obiektu");
    pm.add("nazwaRoliPacjensa-Beneficjenta");
    pm.add("nazwaRoliInstrumentalnej");
    pm.add("nazwaRoliSposobuWykonania");
    pm.add("nazwaRoliWynikowej");
    pm.add("nazwaRoliLokalizujacejWPrzestrzeni");
    pm.add("nazwaRoliReifikujacej");
    pm.add("nazwaRoliPrzedmiotowej");
    pm.add("nazwaRoliPodmiotowej");
 
    final JLabel l1 = new JLabel("Nazwa aktywnosci:");
    final JLabel l2 = new JLabel("Rola w planie:");
    final JLabel l3 = new JLabel("Typ Roli:");
    final JLabel l4 = new JLabel("Klasyfikuje");
    final JComboBox cb = new JComboBox(pm.toArray());
    final JTextField klas = new JTextField();
    final JTextField tf = new JTextField();
    final JTextField tf2 = new JTextField();
    final JButton gap = new JButton();
 final JButton add = new JButton(jButton34.getIcon());
    final ActionListener l = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                 rola_w_planie.add(tf2.getText()+", klasyfikuje: " + klas.getText());
              tf2.setText("");
              klas.setText("");                 add.setEnabled(false);
              f.validate();
f.repaint();
            }
        };
   
     final JButton ok = new JButton("OK");
          klas.addActionListener(new ActionListener() {

             @Override
             public void actionPerformed(ActionEvent e) {
                 add.setEnabled(true);
             }
         });
    cb.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                  ActionListener al = null;
            if (cb.getSelectedItem().toString().equals("nazwaRoliWynikowej"))
            {

                    content.remove(l2);
                    content.remove(tf2);
                    content.remove(add);
                    add.removeActionListener(l);
                    content.remove(l4);
                    content.remove(klas);
                    List items = new ArrayList();
                    items.add("nazwaRoli-SkutkuRozpoczynanego");
                    items.add("nazwaRoli-SkutkuKonczonego");
                    final JComboBox jc = new JComboBox(items.toArray());
                    content.add(jc);
                    content.add(tf2);
                    content.add(add);
                  
                    al = new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                                rola_w_planie.add(tf2.getText()+" typu "+jc.getSelectedItem().toString()+", klasyfikuje: " + klas.getText());
              tf2.setText("");
              klas.setText("");
                               add.setEnabled(false);
              f.validate();
f.repaint();
                    }
                };
                    add.addActionListener(al);
                    content.add(l4);
                    content.add(klas);
                    
                    
                    
                    f.invalidate();
f.validate();
f.repaint();
            }
            else
            {
                content.removeAll();
                try{
                add.removeActionListener(al);
                }
                catch (Exception exc){}
                add.addActionListener(l);
                
                    content.add(l1);
    content.add(tf);
    content.add(ok);
    content.add(l3);
    content.add(cb);    
    content.add(gap);
    content.add(l2);
    content.add(tf2);
    content.add(add);
    content.add(l4);
    content.add(klas);
                
                
            }
            }
        });
    
    
   
     
    gap.setVisible(false);

    add.addActionListener(l);
    
   
    
    ok.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               
                DefaultMutableTreeNode zd = new DefaultMutableTreeNode("Specyfikacja aktywności");
                DefaultMutableTreeNode nazwa = new DefaultMutableTreeNode("Nazwa Akttywności: "+tf.getText() );
                zd.add(nazwa);
                for (int i = 0;i<rola_w_planie.size();i++)
                {
                    DefaultMutableTreeNode rola;
                          rola  = new DefaultMutableTreeNode(cb.getSelectedItem().toString() +  ": "+ rola_w_planie.get(i));
                          zd.add(rola);
                }
                 if (jComboBox1.getSelectedIndex() ==0) {
            searchNode_and_add_child("Plan reprezentujący deskrypcję sytuacji", zd);
        } else {
            searchNode_and_add_child("Plan reprezentujący deskrypcję sytuacji "+ (jComboBox1.getSelectedIndex()+1),zd);
        }
                 f.hide();
            }
        });
  
    content.add(l1);
    content.add(tf);
    content.add(ok);
    content.add(l3);
    content.add(cb);    
    content.add(gap);
    content.add(l2);
    content.add(tf2);
    content.add(add);
    content.add(l4);
    content.add(klas);

    f.setSize(800, 200);
    f.show();
   
        
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
   
        
        // TODO add your handling code here:

         final JFrame f = new JFrame() ;
    
  //  Container content = f.getContentPane();
    final JPanel content = new JPanel(); 
    JScrollPane jsp = new JScrollPane(content);
    f.add(jsp);
    rola_w_planie = new ArrayList();
    content.setBackground(Color.white);
    content.setBackground(Color.white);
    content.setLayout(new GridLayout(0,3));
    List pm = new ArrayList();
    pm.add("nazwaRoliAgentywnej");
    pm.add("nazwaRoliPacjensa-Obiektu");
    pm.add("nazwaRoliPacjensa-Beneficjenta");
    pm.add("nazwaRoliInstrumentalnej");
    pm.add("nazwaRoliSposobuWykonania");
    pm.add("nazwaRoliWynikowej");
    pm.add("nazwaRoliLokalizujacejWPrzestrzeni");
    pm.add("nazwaRoliReifikujacej");
    pm.add("nazwaRoliPrzedmiotowej");
    pm.add("nazwaRoliPodmiotowej");
 
    final JLabel l1 = new JLabel("Nazwa stanu:");
    final JLabel l2 = new JLabel("Rola w planie:");
    final JLabel l3 = new JLabel("Typ Roli:");
    final JLabel l4 = new JLabel("Klasyfikuje");
    final JComboBox cb = new JComboBox(pm.toArray());
    final JTextField klas = new JTextField();
    final JTextField tf = new JTextField();
    final JTextField tf2 = new JTextField();
    final JButton gap = new JButton();
final JButton add = new JButton(jButton34.getIcon());
    final ActionListener l = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                 rola_w_planie.add(tf2.getText()+", klasyfikuje: " + klas.getText());
              tf2.setText("");
              klas.setText("");
                               add.setEnabled(false);
              f.validate();
f.repaint();
            }
        };
    
    
      klas.addActionListener(new ActionListener() {

             @Override
             public void actionPerformed(ActionEvent e) {
                 add.setEnabled(true);
             }
         });
    
     final JButton ok = new JButton("OK");
    cb.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                  ActionListener al = null;
            if (cb.getSelectedItem().toString().equals("nazwaRoliWynikowej"))
            {

                    content.remove(l2);
                    content.remove(tf2);
                    content.remove(add);
                    add.removeActionListener(l);
                    content.remove(l4);
                    content.remove(klas);
                    List items = new ArrayList();
                    items.add("nazwaRoli-SkutkuRozpoczynanego");
                    items.add("nazwaRoli-SkutkuKonczonego");
                    final JComboBox jc = new JComboBox(items.toArray());
                    content.add(jc);
                    content.add(tf2);
                    content.add(add);
                  
                    al = new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                                rola_w_planie.add(tf2.getText()+" typu "+jc.getSelectedItem().toString()+", klasyfikuje: " + klas.getText());
              tf2.setText("");
              klas.setText("");
               add.setEnabled(false);
              f.validate();
f.repaint();
                    }
                };
                    add.addActionListener(al);
                    content.add(l4);
                    content.add(klas);
                    
                    
                    
                    f.invalidate();
f.validate();
f.repaint();
            }
            else
            {
                content.removeAll();
                try{
                add.removeActionListener(al);
                }
                catch (Exception exc){}
                add.addActionListener(l);
                
                    content.add(l1);
    content.add(tf);
    content.add(ok);
    content.add(l3);
    content.add(cb);    
    content.add(gap);
    content.add(l2);
    content.add(tf2);
    content.add(add);
    content.add(l4);
    content.add(klas);
                
                
            }
            }
        });
    
    
   
     
    gap.setVisible(false);

    add.addActionListener(l);
    
   
    
    ok.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               
                DefaultMutableTreeNode zd = new DefaultMutableTreeNode("Specyfikacja stanu");
                DefaultMutableTreeNode nazwa = new DefaultMutableTreeNode("Nazwa ztanu: "+tf.getText() );
                zd.add(nazwa);
                for (int i = 0;i<rola_w_planie.size();i++)
                {
                    DefaultMutableTreeNode rola;
                          rola  = new DefaultMutableTreeNode(cb.getSelectedItem().toString() +  ": "+ rola_w_planie.get(i));
                          zd.add(rola);
                }
                 if (jComboBox1.getSelectedIndex() ==0) {
            searchNode_and_add_child("Plan reprezentujący deskrypcję sytuacji", zd);
        } else {
            searchNode_and_add_child("Plan reprezentujący deskrypcję sytuacji "+ (jComboBox1.getSelectedIndex()+1),zd);
        }
                 f.hide();
            }
        });
  
    content.add(l1);
    content.add(tf);
    content.add(ok);
    content.add(l3);
    content.add(cb);    
    content.add(gap);
    content.add(l2);
    content.add(tf2);
    content.add(add);
    content.add(l4);
    content.add(klas);

    f.setSize(800, 200);
    f.show();
   
 
        
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:

          

          plan_count++;
           searchNode_and_add_child("Część ustrukturalizowana opisu", "Plan reprezentujący deskrypcję sytuacji " + plan_count );

        
        searchNode_and_add_child("Plan reprezentujący deskrypcję sytuacji " + plan_count,"Nazwa planu");
      
        jComboBox1.addItem(plan_count);
        jComboBox1.setSelectedIndex(plan_count-1);
jComboBox1.getSelectedIndex();
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed

        String s = jTextField2.getText();

                
        searchNode_and_Replace(jTextField2.getToolTipText(), "Nazwa sytuacji : " + s);
        jTextField2.setToolTipText("Nazwa sytuacji : " + s);
jTextField2.setForeground(Color.decode("#8fc400"));

        // TODO add your handling code here:




    }//GEN-LAST:event_jTextField2ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:

        JFileChooser fc = new JFileChooser();
        
        xmlFilter xf = new xmlFilter();
        fc.setFileFilter(xf);
        int returnVal = fc.showSaveDialog(MyJApplet.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
             file = new File(file.getPath()+".xml");
            //This is where a real application would save the file.
            BufferedWriter bw;
            try {
                bw = new BufferedWriter(new FileWriter(file));
                bw.write(jTextArea3.getText());
                bw.flush();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        } else {
        }


    }//GEN-LAST:event_jButton6ActionPerformed


    
    private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField5ActionPerformed
        // TODO add your handling code here:

        //Typ funkcji autora
        String s = jTextField5.getText();
        searchNode_and_Replace(jTextField5.getToolTipText(), "Typ funkcji autora : " + s);
        jTextField5.setToolTipText("Typ funkcji autora : " + s);
jTextField5.setForeground(Color.decode("#8fc400"));

    }//GEN-LAST:event_jTextField5ActionPerformed

    private void jTextField10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField10ActionPerformed
        // TODO add your handling code here:



        String s = jTextField10.getText();
        searchNode_and_Replace(jTextField10.getToolTipText(), "Nazwa identyfikująca autora : " + s);
        jTextField10.setToolTipText("Nazwa identyfikująca autora : " + s);
        jTextField10.setForeground(Color.decode("#8fc400"));
        

    }//GEN-LAST:event_jTextField10ActionPerformed

    private void textAreaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textAreaKeyTyped
        // TODO add your handling code here:

        String s = jTextArea1.getText();
        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        DefaultMutableTreeNode m_rootNode = (DefaultMutableTreeNode) model.getRoot();
        DefaultMutableTreeNode node = null;
        node = (DefaultMutableTreeNode) m_rootNode.getChildAt(m_rootNode.getChildCount() - 1);
        node.setUserObject("Część swobodna opisu : " + s);
        model.reload(node);

        jTextArea1.setToolTipText("Część swobodna opisu : " + s);
    }//GEN-LAST:event_textAreaKeyTyped

    private void jtree1_propertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jtree1_propertyChange
        // TODO add your handling code here:
        reload_scan_xml();

    }//GEN-LAST:event_jtree1_propertyChange

      List fields;
    List buttons ;
    
    
    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
        TreePath  toremove = jTree1.getSelectionPath();
DefaultMutableTreeNode rem = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        model.removeNodeFromParent(rem);
        
        
    }//GEN-LAST:event_jButton9ActionPerformed

     List allNodes;
       public class pattern_match
    {
        public String match;
        public int count;
    }
       
        JTextArea ta ;
    
        String replace_me = "|";
        
    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        try{
        content_driven_GUI gui = new content_driven_GUI();
        }
        catch(Exception w)
        {
            new MessageBox("Błąd w pliku wejściowym.").show();
        }
/*             JFileChooser fc = new JFileChooser();
        int returnVal = fc.showOpenDialog(MyJApplet.this);
        fc.setCurrentDirectory(new File(System.getProperty("user.home")));
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
             
            try {
       BufferedReader reader = new BufferedReader(new FileReader(file));
       String line;
       
           while ((line = reader.readLine()) != null)
    {
     global_pattern += line;
     
    }

           
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder;
Document doc = null;
                try {   
                    dBuilder = dbFactory.newDocumentBuilder();try {
                        doc = dBuilder.parse(file);
                    } catch (SAXException ex) {
                        Logger.getLogger(MyJApplet.class.getName()).log(Level.SEVERE, null, ex);
                    }
                } catch (ParserConfigurationException ex) {
                    Logger.getLogger(MyJApplet.class.getName()).log(Level.SEVERE, null, ex);
                }

doc.getDocumentElement().normalize();
Element root = doc.getDocumentElement();  

 NodeList nodes = root.getChildNodes();
 allNodes = new ArrayList()
 {

                    @Override
                    public int indexOf(Object o) {
                        //return super.indexOf(o);
                        try
                        {
                        for (int i =0;i<this.size()-1;i++)
                        {
                            if (((xml_node_container)allNodes.get(i)).node.getNodeName() == ((xml_node_container)o).node.getNodeName()) {
                                return i;
                            }
                        }}
                        catch (Exception e)
                        {
                            return -1;
                        }
                        return -1;
                    }
                    
                    
     
 };
 
  allNodes.add(new xml_node_container(root, 0));

 
  jTree2 = new JTree();
  DefaultMutableTreeNode r = (DefaultMutableTreeNode) jTree2.getModel().getRoot();
 r.setUserObject(root.getNodeName());
 r.removeAllChildren();
  int depth = 1;
  int t = nodes.getLength();
 for (int i = 1; i<t;i+=1)
 {

      int temp = 0;
      String tempo = nodes.item(i).getNodeName();
      if (tempo == "#text") continue;
    // String tempVal = nodes.item(i).getNodeValue();
  //    temp = allNodes_contains(new xml_node_container(nodes.item(i),depth));
      temp = allNodes.indexOf(new xml_node_container(nodes.item(i),depth));
    //  boolean check = (temp > -1 && ((xml_node_container)allNodes.get(temp)).node.getParentNode().getNodeName().equals(nodes.item(i).getParentNode().getNodeName()));
  if (temp > -1)
  {
      ((xml_node_container)allNodes.get(temp)).setIs_multinode();
      continue;
  } 
  
  r.add(new DefaultMutableTreeNode(nodes.item(i).getNodeName()));
     if (ma_dzieci(nodes.item(i))) {
        allNodes.add(new xml_node_container(nodes.item(i), depth,true));  
     }
       
     else{
        allNodes.add(new xml_node_container(nodes.item(i), depth));
     }

     if (ma_dzieci(nodes.item(i)))
     {
          NodeList test = nodes.item(i).getChildNodes();
           Node test2 = nodes.item(i).getFirstChild();
            addChildstoNode(nodes.item(i).getChildNodes(),(DefaultMutableTreeNode)r.getLastChild(), ++depth);

     }
     
 }    
    JFrame f = new JFrame("Wygenreowany formularz") ;
    
  //  Container content = f.getContentPane();
    JPanel content = new JPanel(); 
    JScrollPane jsp = new JScrollPane(content);
    f.add(jsp);
    content.setBackground(Color.white);
    content.setLayout(new GridLayout(0,3));
    //JTree j = new JTree(l.get(0));
      fields = new ArrayList();
     buttons = new ArrayList();
    Boolean is_in_form = false;

    
   f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
  //f.setsize
  // f.add(jTree2);
   boolean bylo = false;
   int test = allNodes.size();
  
   for (int i = 1;i<allNodes.size();i++)
   {

       JLabel templabel = new JLabel(((xml_node_container)allNodes.get(i)).node.getNodeName());
       JTextField tf = new JTextField();
       
      
       tf.addActionListener(new ActionListener() {

           @Override
           public void actionPerformed(ActionEvent e) {
               int containerIdx=-1;
               
                for (int i=0;i<fields.size();i++)
                   {
                       if (fields.get(i).equals(e.getSource()))
                       {
                           containerIdx = i;
                           break;
                       }
                   }
                int nodeIdx = containerIdx +1;
            String t = "<"+((xml_node_container)allNodes.get(nodeIdx)).node.getNodeName() + ">"+((JTextField)fields.get(containerIdx)).getText() + "</"+((xml_node_container)allNodes.get(nodeIdx)).node.getNodeName() + ">\n";
               int wciecie =  ((xml_node_container)allNodes.get(nodeIdx)).depth;
                         for (int i = 0;i<wciecie;i++) {
                               t="\t"+t;
                           }
               
               ((JTextField)fields.get(containerIdx)).setToolTipText(t);
               ((JTextField)fields.get(containerIdx)).setBackground(Color.decode("#8fc400"));
           }
       });
       
       
      
       boolean testVis = ((xml_node_container)allNodes.get(i)).is_just_parrent;
       tf.setVisible(!((xml_node_container)allNodes.get(i)).is_just_parrent);
       JButton butt = new JButton(jButton1.getIcon());
       boolean isMultonode = ((xml_node_container)allNodes.get(i)).is_multinode;
       butt.setVisible(((xml_node_container)allNodes.get(i)).is_multinode);
       butt.setToolTipText("");
       butt.addActionListener(new ActionListener() {

               @Override
               public void actionPerformed(ActionEvent e) {
                  int containerIndex =-1;
                   for (int i=0;i<buttons.size();i++)
                   {
                       if (buttons.get(i).equals(e.getSource()))
                       {
                           containerIndex = i;
                           break;
                       }
                   }
                  // temp++; //TUTAJ MUSI BYC PLUS JEDEN BO BUTTONY LICZYMY OD 0 A ELEMENTY TAK NAPRAWDE OD 1 BO 0 TO JEST ROOT
                       int childContainerIndex = containerIndex+1;
                       int nodeIndex = containerIndex +1;
                       int childNodeIndex = nodeIndex+1;
                       
                       if (((xml_node_container)allNodes.get(nodeIndex)).node.getNodeType() == Node.TEXT_NODE)
                       {
                          
                           String dodaj = "";
                            int wciecie =  ((xml_node_container)allNodes.get(nodeIndex)).depth;
                         for (int i = 0;i<wciecie;i++) {
                               dodaj+="\t";
                           }
                
                          dodaj += ((JTextField)fields.get(containerIndex)).getToolTipText();
                        
                          ((JButton)buttons.get(containerIndex)).setToolTipText(((JButton)buttons.get(containerIndex)).getToolTipText()+dodaj);
                       ((JTextField)fields.get(containerIndex)).setText(null);
                       ((JTextField)fields.get(containerIndex)).setToolTipText(null);
                       ((JTextField)fields.get(containerIndex)).setBackground(Color.white );
                       
                       
                       }
                       else
                       {
                             String dodaj ="";
                              int wciecie =  ((xml_node_container)allNodes.get(nodeIndex)).depth;
                         for (int i = 0;i<wciecie;i++) {
                               dodaj+="\t";
                           }
                          
                           dodaj += "<"+((xml_node_container)allNodes.get(nodeIndex)).node.getNodeName()+">\n";
                     //      ta.setText(ta.getText().replace(replace_me, dodaj + replace_me));
                                   
                   try{
                       while (((xml_node_container)allNodes.get(nodeIndex)).depth < ((xml_node_container)allNodes.get(childNodeIndex)).depth)
                       {  
                           int wciecie3 =  ((xml_node_container)allNodes.get(childNodeIndex)).depth;
                         for (int i = 0;i<wciecie3;i++) {
                               dodaj+="\t";
                           }
                          try{
                              
                               
                               
                          
                           dodaj += "<"+((xml_node_container)allNodes.get(childNodeIndex)).node.getNodeName()+">" + ((JTextField)fields.get(childContainerIndex)).getText()+"</"+((xml_node_container)allNodes.get(childNodeIndex)).node.getNodeName()+">\n\r";
                        //   ta.setText(ta.getText().replace(replace_me, dodaj+replace_me));
                           ((JTextField)fields.get(childContainerIndex)).setBackground(Color.white);
                           ((JTextField)fields.get(childContainerIndex)).setText(null);
                           ((JTextField)fields.get(childContainerIndex)).setToolTipText(null);
                           
                           
                          }
                          catch (Exception exc)
                                  {
                                   break;
                                  }
                           childContainerIndex++;
                           childNodeIndex++;
                       }
                   }
                     catch (Exception exc)
                                  {
                                  //OutOfArray
                                  }
                             int wciecie4 =  ((xml_node_container)allNodes.get(nodeIndex)).depth;
                         for (int i = 0;i<wciecie4;i++) {
                               dodaj+="\t";
                           }    
                           dodaj += "</"+((xml_node_container)allNodes.get(nodeIndex)).node.getNodeName()+">\n";
                          // ta.setText(ta.getText().replace(replace_me, dodaj + replace_me));
                         
                           ((JButton)buttons.get(containerIndex)).setToolTipText(((JButton)buttons.get(containerIndex)).getToolTipText()+dodaj);
                       }
                       
                   
                   
                   
               }
               
           });
  
     
       content.add(templabel);
       content.add(tf);
       fields.add(tf);
       buttons.add(butt);
      
       content.add(butt);
       
       butt = null;
       tf = null;
       templabel = null;
   }

      ta = new JTextArea("<"+((xml_node_container)allNodes.get(0)).node.getNodeName() +">\n\r"+"\n</"+((xml_node_container)allNodes.get(0)).node.getNodeName()+">");
    
    JButton gap = new JButton();
    gap.setVisible(false);
    content.add(gap);
    gap = null;
    gap = new JButton();
    gap.setVisible(false);
    content.add(gap);
    JButton refr = new JButton("Odśwież");// = new JButton(jLabel15.getIcon());
    refr.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                      ta.setText("<" + ((xml_node_container)allNodes.get(0)).node.getNodeName() + ">\n");
                        
                        String dodaj="";
                      
                      for (int i = 0; i < fields.size();i++)
                      {
                          if (((JButton)buttons.get(i)).getToolTipText() != null)
                          {
                              String t = ((JButton)buttons.get(i)).getToolTipText();
                              dodaj+= ((JButton)buttons.get(i)).getToolTipText();
                          }
                          else
                          {
                          if (((JTextField)fields.get(i)).getToolTipText() != null) {
                                  dodaj += ((JTextField)fields.get(i)).getToolTipText();
                              }
                          }
                      }
                      ta.setText(ta.getText()+ dodaj + "</" + ((xml_node_container)allNodes.get(0)).node.getNodeName() + ">");
                    }
                });
    
    
    refr.setSize(100, 100);
        content.add(refr);
    
      content.add(new JLabel("Podgląd pliku"));
   
     content.add(ta);
     JButton zapis = new JButton("Zapisz");
     zapis.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                            JFileChooser fc = new JFileChooser();
        int returnVal = fc.showSaveDialog(MyJApplet.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            //This is where a real application would save the file.
            BufferedWriter bw;
            try {
                bw = new BufferedWriter(new FileWriter(file));
                bw.write(ta.getText());
                bw.flush();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        } else {
        }
                    }
                });
     content.add(zapis);
     f.setSize(600, 800);
    f.setVisible(true);
    
    
       
       
    reader.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        } else {
        }
        
   */     
    }//GEN-LAST:event_jButton7ActionPerformed
JTextField cel_pod;
    private void jButton34ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton34ActionPerformed
        // TODO add your handling code here:
        final JFrame f = new JFrame("Dodaj cel podrzędny") ;
    
  //  Container content = f.getContentPane();
    JPanel content = new JPanel(); 
    JScrollPane jsp = new JScrollPane(content);
    f.add(jsp);
    content.setBackground(Color.white);
    content.setLayout(new GridLayout(0,2));
    cel_pod = new JTextField();
    content.add(cel_pod);
    JButton ok = new JButton("OK");
    ok.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("Cel podrzędny: "+cel_pod.getText());
                searchNode_and_add_child("Część ustrukturalizowana opisu", node2);
        jTree1.repaint();
               f.hide();
        
            }
        });
    content.add(ok);f.setSize(400, 200);
    f.show();
        
    }//GEN-LAST:event_jButton34ActionPerformed

    private void jButton35ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton35ActionPerformed
        // TODO add your handling code here:
        
                       String lab = "Typ Bazowy";
        if (jComboBox2.getSelectedIndex() ==0) {
          searchNode_and_add_child(lab,"Jest podtypem: "+jTextField60.getText());
        } else {
            searchNode_and_add_child(lab+" "+ jComboBox2.getSelectedItem().toString(),"Jest podtypem: "+jTextField60.getText());
        }
        jTextField60.setText("");
    }//GEN-LAST:event_jButton35ActionPerformed

    private void jButton36ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton36ActionPerformed
        // TODO add your handling code here:
        
                       String lab = "Typ Bazowy";
        if (jComboBox2.getSelectedIndex() ==0) {
          searchNode_and_add_child(lab,"Ma podtypy: "+jTextField61.getText());
        } else {
            searchNode_and_add_child(lab+" "+ jComboBox2.getSelectedItem().toString(),"Ma podtyp: "+jTextField61.getText());
        }
        jTextField61.setText("");
    }//GEN-LAST:event_jButton36ActionPerformed

    private void jButton37ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton37ActionPerformed
        // TODO add your handling code here:
               String lab = "Typ Bazowy";
        if (jComboBox2.getSelectedIndex() ==0) {
          searchNode_and_add_child(lab,"Jest klasyfikowany przez: "+jTextField59.getText());
        } else {
            searchNode_and_add_child(lab+" "+ jComboBox2.getSelectedItem().toString(),"Jest pasyfikowany przez: "+jTextField59.getText());
        }
        jTextField59.setText("");
        
    }//GEN-LAST:event_jButton37ActionPerformed

    private void glowny_cel(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_glowny_cel
        // TODO add your handling code here:
        
         String s = jTextField1.getText();

                
        searchNode_and_Replace(jTextField1.getToolTipText(), "Cel główny planu : " + s);
        jTextField1.setToolTipText("Cel główny planu : " + s);
        jTextField1.setForeground(Color.decode("#8fc400"));
    }//GEN-LAST:event_glowny_cel

    private void jTextField62ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField62ActionPerformed
        // TODO add your handling code here:
         
        String lab = "Plan reprezentujący deskrypcję sytuacji";
        if (jComboBox1.getSelectedIndex() ==0) {
          searchNode_and_replace_child(lab,0,"Nazwa: "+jTextField62.getText());
        } else {
            searchNode_and_replace_child(lab+" "+ jComboBox1.getSelectedItem().toString(),0,"Nazwa: "+jTextField62.getText());
        }
        jTextField62.setForeground(Color.decode("#8fc400"));
    }//GEN-LAST:event_jTextField62ActionPerformed
 int base_type_count = 1;
    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        // TODO add your handling code here:
           base_type_count++;
        searchNode_and_add_child("Część ustrukturalizowana opisu", "Typ Bazowy " + base_type_count);
        searchNode_and_add_child("Typ Bazowy " + base_type_count,"Nazwa");
      
        jComboBox2.addItem(base_type_count);
        jComboBox2.setSelectedIndex(base_type_count-1);

        
        
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        // TODO add your handling code here:
        
                String lab = "Typ Bazowy";
        if (jComboBox2.getSelectedIndex() ==0) {
          searchNode_and_replace_child(lab,0,"Nazwa: "+jTextField3.getText());
        } else {
            searchNode_and_replace_child(lab+" "+ jComboBox2.getSelectedItem().toString(),0,"Nazwa: "+jTextField3.getText());
        }
        jTextField3.setForeground(Color.decode("#8fc400"));
    }//GEN-LAST:event_jTextField3ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        // TODO add your handling code here:

            
	{// TODO add your handling code here:
       int i=0;
        try{
       
    // String header = "<?xml version=\"1.0\" standalone=\"yes\" encoding=\"utf-16\"?>\n<opisScenariusza>\n";
      String czesc_ustrukturalizowana = "\t<czescUstrukturalizowanaScenariusza>\n";
      String plany = "";
      String typy_bazowe = "";
   //   String cele_podrzedne = "\t\t<celPlanuDzialanAktywnosciZdarzenStanow>\n|\t\t</celPlanuDzialanAktywnosciZdarzenStanow>\n";
      String cele = "\t\t<celPlanuDzialanAktywnosciZdarzenStanow>\n|\t\t</celPlanuDzialanAktywnosciZdarzenStanow>\n";
      
      DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        DefaultMutableTreeNode m_rootNode = (DefaultMutableTreeNode) model.getRoot();
        DefaultMutableTreeNode cz_us = (DefaultMutableTreeNode) m_rootNode.getChildAt(0);
            int test = cz_us.getChildCount();
        for (i = 0;i<cz_us.getChildCount();i++)
        {
            DefaultMutableTreeNode temp = (DefaultMutableTreeNode) cz_us.getChildAt(i);
            if (temp.getUserObject().toString().contains("Nazwa sytuacji"))
            {
                try{
                String [] spitter = temp.getUserObject().toString().split(":");
                czesc_ustrukturalizowana += "\t\t<nazwa_sytuacji>"+ spitter[1] + "</nazwa_sytuacji>\n";
                }
                catch(Exception xc)
                {
                    czesc_ustrukturalizowana += "\t\t<nazwa_sytuacji>" + "</nazwa_sytuacji>\n";
                    
                }
            }
            if (temp.getUserObject().toString().contains("Cel główny"))
            {
                try
                {
                String [] spitter = temp.getUserObject().toString().split(":");
                
                cele = cele.replace("|",  "\t\t\t<celGlowny>"+ spitter[1] + "</celGlowny>\n");
                }
                  catch(Exception xc)
                {
                   cele = cele.replace("|",  "\t\t\t<celGlowny>"+ "</celGlowny>\n");      
                }
                
            } 
              if (temp.getUserObject().toString().contains("Cel podrzędny"))
            {
                try
                {
                String [] spitter = temp.getUserObject().toString().split(":");
                //cele += "\t\t<celPodrzędny>"+ spitter[1] + "</celPodrzędny>\n";
                 cele = cele.replace("|",  "\t\t\t<celPodrzędny>"+ spitter[1] + "</celPodrzędny>\n");
                }
                  catch(Exception xc)
                {
                    cele = cele.replace("|",  "\t\t\t<celPodrzędny>"+ "</celPodrzędny>\n");
                }
                
            } 
            if (temp.getUserObject().toString().contains("Specyfikajcja danych autora scenariusza"))
            {
                String [] spitter;
                czesc_ustrukturalizowana +="\t\t<specyfikacjaDanychAutoraScenariusza>\n";
                try
                        {
              spitter = ((DefaultMutableTreeNode)temp.getChildAt(0)).getUserObject().toString().split(":");
                czesc_ustrukturalizowana += "\t\t\t<typFunkcjiAutora>"+ spitter[1] + "</typFunkcjiAutora>\n";
                        }
                          catch(Exception xc)
                {
                      czesc_ustrukturalizowana += "\t\t\t<typFunkcjiAutora></typFunkcjiAutora>\n";
                }
                try
                {
                 spitter = ((DefaultMutableTreeNode)temp.getChildAt(1)).getUserObject().toString().split(":");
                 czesc_ustrukturalizowana += "\t\t\t<nazwaIdentfikujacaAutora>"+ spitter[1] + "</nazwaIdentfikujacaAutora>\n";
                 czesc_ustrukturalizowana +="\t\t</specyfikacjaDanychAutoraScenariusza>\n";
                        }
                            catch(Exception xc)
                {
                   czesc_ustrukturalizowana += "\t\t\t<nazwaIdentfikujacaAutora>"+  "</nazwaIdentfikujacaAutora>\n";
                 czesc_ustrukturalizowana +="\t\t</specyfikacjaDanychAutoraScenariusza>\n";
                }
            }
            if (temp.getUserObject().toString().contains("Specyfikacja danych zespołu"))
            {
                try{
              String [] spitter = temp.getUserObject().toString().split(":");
                czesc_ustrukturalizowana += "\t\t<specyfikacjaDanychZespoluAutoraScenariusza>"+ spitter[1] + "</specyfikacjaDanychZespoluAutoraScenariusza>\n";
                }
                       catch(Exception xc)
                {
                  czesc_ustrukturalizowana += "\t\t<specyfikacjaDanychZespoluAutoraScenariusza>"+  "</specyfikacjaDanychZespoluAutoraScenariusza>\n";
                 
                }
                }
           
            
            if (temp.getUserObject().toString().contains("Data"))
            {
                try{
              String [] spitter = temp.getUserObject().toString().split(":");
                czesc_ustrukturalizowana += "\t\t<dataOpisuScenariusza>"+ spitter[1] + "</dataOpisuScenariusza>\n";
                }
                       catch(Exception xc)
                {
                     czesc_ustrukturalizowana += "\t\t<dataOpisuScenariusza>" + "</dataOpisuScenariusza>\n";
                }
            }
             if (temp.getUserObject().toString().contains("Plan reprezentujący deskrypcję sytuacji"))
            {
                plany +="\t\t<planReprezentujacyDeskrypcjeSytuacji>\n";
                
              
                for (int j = 0; j<temp.getChildCount();j++)
                {
                    DefaultMutableTreeNode plan_child = (DefaultMutableTreeNode) temp.getChildAt(j);
                    if (plan_child.getUserObject().toString().contains("Nazwa"))
                    {
                        try{
                        String [] spitter = plan_child.getUserObject().toString().split(":");
                                  plany += "\t\t\t<nazwaPlanu>"+ spitter[1] + "</nazwaPlanu>\n";
                        }
                        catch( Exception es)
                        {
                         plany += "\t\t\t<nazwaPlanu>"+  "</nazwaPlanu>\n";
                        }
                    }
                    if (plan_child.getUserObject().toString().contains("Specyfikacja zadnia"))
                      {
                          plany += "\t\t\t<specyfikacjaZadania>\n";
                          
                          

   for (int k = 0; k<plan_child.getChildCount();k++)
                          {
                              DefaultMutableTreeNode  plan_grandchild = (DefaultMutableTreeNode) plan_child.getChildAt(k);
                            if (plan_grandchild.getUserObject().toString().contains("Nazwa")) 
                            {
                                try
                                {
                                 String [] spitter = plan_grandchild.getUserObject().toString().split(":");
                                  plany += "\t\t\t\t<nazwaZadaniaWPlanieReprezentujacymDeskrypcjeSytuacji>"+ spitter[1] + "</nazwaZadaniaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                                 catch( Exception es)
                        {
                            plany += "\t\t\t\t<nazwaZadaniaWPlanieReprezentujacymDeskrypcjeSytuacji>" + "</nazwaZadaniaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                               
                        }
                            } 
                            else
                            {
                                try
                                {
                                 String [] spitter = plan_grandchild.getUserObject().toString().split(",");
                                 String [] spliter_roli = spitter[0].split(":");
                                 String [] spliter_klasyfikacji = spitter[1].split(":");
                                  plany += "\t\t\t\t<rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                   plany += "\t\t\t\t\t<"+spliter_roli[0]+">"+spliter_roli[1]+"</"+spliter_roli[0]+">\n";
                                   plany += "\t\t\t\t\t<klasyfikuje>"+spliter_klasyfikacji[1]+"</klasyfikuje>\n";
                                   plany += "\t\t\t\t</rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                                catch (Exception ex)
                                {
                                   plany += "\t\t\t\t<rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                   plany += "\t\t\t\t\t<rola>"+"</rola>\n";
                                   plany += "\t\t\t\t\t<klasyfikuje>"+"</klasyfikuje>\n";
                                   plany += "\t\t\t\t</rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                            } 
                            
                          }
                          
                           plany += "\t\t\t</specyfikacjaZadania>\n";
                       
                      }
                    
                    
                    if (plan_child.getUserObject().toString().contains("Specyfikacja aktywności"))
                      {
                          plany += "\t\t\t<specyfikacjaAktywnosci>\n";
                        
                          

   for (int k = 0; k<plan_child.getChildCount();k++)
                          {
                              DefaultMutableTreeNode  plan_grandchild = (DefaultMutableTreeNode) plan_child.getChildAt(k);
                            if (plan_grandchild.getUserObject().toString().contains("Nazwa")) 
                            {
                                try
                                {
                                 String [] spitter = plan_grandchild.getUserObject().toString().split(":");
                                  plany += "\t\t\t\t<nazwaAktywnosciWPlanieReprezentujacymDeskrypcjeSytuacji>"+ spitter[1] + "</nazwaAktywnosciWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                                 catch( Exception es)
                        {
                            plany += "\t\t\t\t<nazwaAktywnosciWPlanieReprezentujacymDeskrypcjeSytuacji>" + "</nazwaAktywnosciWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                               
                        }
                            } 
                            else
                            {
                                try
                                {
                                 String [] spitter = plan_grandchild.getUserObject().toString().split(",");
                                 String [] spliter_roli = spitter[0].split(":");
                                 String [] spliter_klasyfikacji = spitter[1].split(":");
                                  plany += "\t\t\t\t<rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                   plany += "\t\t\t\t\t<"+spliter_roli[0]+">"+spliter_roli[1]+"</"+spliter_roli[0]+">\n";
                                   plany += "\t\t\t\t\t<klasyfikuje>"+spliter_klasyfikacji[1]+"</klasyfikuje>\n";
                                   plany += "\t\t\t\t</rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                                catch (Exception ex)
                                {
                                   plany += "\t\t\t\t<rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                   plany += "\t\t\t\t\t<rola>"+"</rola>\n";
                                   plany += "\t\t\t\t\t<klasyfikuje>"+"</klasyfikuje>\n";
                                   plany += "\t\t\t\t</rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                            } 
                            
                          }
                          
                           plany += "\t\t\t</specyfikacjaAktywnosci>\n";
                       
                      }
                     if (plan_child.getUserObject().toString().contains("Specyfikacja zdarzenia"))
                      {
                          plany += "\t\t\t<specyfikacjaZdarzenia>\n";
                         

   for (int k = 0; k<plan_child.getChildCount();k++)
                          {
                              DefaultMutableTreeNode  plan_grandchild = (DefaultMutableTreeNode) plan_child.getChildAt(k);
                            if (plan_grandchild.getUserObject().toString().contains("Nazwa")) 
                            {
                                try
                                {
                                 String [] spitter = plan_grandchild.getUserObject().toString().split(":");
                                  plany += "\t\t\t\t<nazwaZdarzeniaWPlanieReprezentujacymDeskrypcjeSytuacji>"+ spitter[1] + "</nazwaZdarzeniaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                                 catch( Exception es)
                        {
                            plany += "\t\t\t\t<nazwaZdarzeniaWPlanieReprezentujacymDeskrypcjeSytuacji>" + "</nazwaZdarzeniaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                               
                        }
                            } 
                            else
                            {
                                try
                                {
                                 String [] spitter = plan_grandchild.getUserObject().toString().split(",");
                                 String [] spliter_roli = spitter[0].split(":");
                                 String [] spliter_klasyfikacji = spitter[1].split(":");
                                  plany += "\t\t\t\t<rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                   plany += "\t\t\t\t\t<"+spliter_roli[0]+">"+spliter_roli[1]+"</"+spliter_roli[0]+">\n";
                                   plany += "\t\t\t\t\t<klasyfikuje>"+spliter_klasyfikacji[1]+"</klasyfikuje>\n";
                                   plany += "\t\t\t\t</rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                                catch (Exception ex)
                                {
                                   plany += "\t\t\t\t<rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                   plany += "\t\t\t\t\t<rola>"+"</rola>\n";
                                   plany += "\t\t\t\t\t<klasyfikuje>"+"</klasyfikuje>\n";
                                   plany += "\t\t\t\t</rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                            } 
                            
                          }
                           plany += "\t\t\t</specyfikacjaZdarzenia>\n";
                       
                      }
                    if (plan_child.getUserObject().toString().contains("Specyfikacja stanu"))
                      {
                          plany += "\t\t\t<opisStanu>\n";
                          
                             for (int k = 0; k<plan_child.getChildCount();k++)
                                                    {
                              DefaultMutableTreeNode  plan_grandchild = (DefaultMutableTreeNode) plan_child.getChildAt(k);
                            if (plan_grandchild.getUserObject().toString().contains("Nazwa")) 
                            {
                                try
                                {
                                 String [] spitter = plan_grandchild.getUserObject().toString().split(":");
                                  plany += "\t\t\t\t<nazwaStanuWPlanieReprezentujacymDeskrypcjeSytuacji>"+ spitter[1] + "</nazwaStanuWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                                 catch( Exception es)
                        {
                            plany += "\t\t\t\t<nazwaStanuWPlanieReprezentujacymDeskrypcjeSytuacji>" + "</nazwaStanuWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                               
                        }
                            } 
                            else
                            {
                                try
                                {
                                 String [] spitter = plan_grandchild.getUserObject().toString().split(",");
                                 String [] spliter_roli = spitter[0].split(":");
                                 String [] spliter_klasyfikacji = spitter[1].split(":");
                                  plany += "\t\t\t\t<rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                   plany += "\t\t\t\t\t<"+spliter_roli[0]+">"+spliter_roli[1]+"</"+spliter_roli[0]+">\n";
                                   plany += "\t\t\t\t\t<klasyfikuje>"+spliter_klasyfikacji[1]+"</klasyfikuje>\n";
                                   plany += "\t\t\t\t</rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                                catch (Exception ex)
                                {
                                   plany += "\t\t\t\t<rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                   plany += "\t\t\t\t\t<rola>"+"</rola>\n";
                                   plany += "\t\t\t\t\t<klasyfikuje>"+"</klasyfikuje>\n";
                                   plany += "\t\t\t\t</rolaWPlanieReprezentujacymDeskrypcjeSytuacji>\n";
                                }
                            } 
                            
                          }
                           plany += "\t\t\t</opisStanu>\n";
                       
                      }
                     
                    
                    
                }
                 
                 
                 
                 
                 jTextArea3.setText(czesc_ustrukturalizowana);
            }
            if (temp.getUserObject().toString().contains("Typ Bazowy"))
            {
                typy_bazowe += "\t\t<bytBazowyUstanawiajacySytuacje>\n";
              for (int j = 0;j< temp.getChildCount();j++)
              {
                  DefaultMutableTreeNode byte_child = (DefaultMutableTreeNode) temp.getChildAt(j);
                   if (byte_child.getUserObject().toString().contains("Nazwa"))
                   {
                       try{
                           
                       
                       String [] splitter =  byte_child.getUserObject().toString().split(":");
                       typy_bazowe += "\t\t\t<nazwaBytu>"+splitter[1]+"</nazwaBytu>\n";
                       }
                       catch (Exception e)
                                {
                                  typy_bazowe += "\t\t\t<nazwaBytu></nazwaBytu>\n";
                                }
                   }
                   if (byte_child.getUserObject().toString().contains("Jest klasyfikowany przez"))
                   {
                       try
                       {
                       String [] splitter =  byte_child.getUserObject().toString().split(":");
                       typy_bazowe += "\t\t\t<jestKlasyfikowanyPrzez>"+splitter[1]+"</jestKlasyfikowanyPrzez>\n";
                       }
                       catch (Exception e)
                       {
                           typy_bazowe += "\t\t\t<jestKlasyfikowanyPrzez></jestKlasyfikowanyPrzez>\n"; 
                       }
                   }
                   
                   if (byte_child.getUserObject().toString().contains("Jest podtypem"))
                   {
                       try
                       {
                       String [] splitter =  byte_child.getUserObject().toString().split(":");
                       typy_bazowe += "\t\t\t<jestPodtypem>"+splitter[1]+"</jestPodtypem>\n";
                       }
                       catch (Exception w)
                       {
                           typy_bazowe += "\t\t\t<jestPodtypem></jestPodtypem>\n";
                       }
                               
                   }
                   if (byte_child.getUserObject().toString().contains("Ma podtyp:"))
                   {
                       try{
                       String [] splitter =  byte_child.getUserObject().toString().split(":");
                       
                       typy_bazowe += "\t\t\t<maPodtyp>"+splitter[1]+"</maPodtyp>\n";
                       }
                       catch (Exception e)
                       {
                           typy_bazowe += "\t\t\t<maPodtyp></maPodtyp>\n";
                       }
                   }
              }
                 typy_bazowe += "\t\t</bytBazowyUstanawiajacySytuacje>\n";
                
            }
        }
        
     String scen_xml = "";
     //scen_xml +=header;
     scen_xml += czesc_ustrukturalizowana;
     scen_xml += cele.replace("|", "");
     plany +="\t\t</planReprezentujacyDeskrypcjeSytuacji>\n";
     scen_xml += plany;
     scen_xml += typy_bazowe;
     scen_xml +=   "\t</czescUstrukturalizowanaScenariusza>\n";
     
    
       DefaultMutableTreeNode cz_do = (DefaultMutableTreeNode) m_rootNode.getChildAt(1);
       try
       {
        String []  czesc_dowolna = cz_do.getUserObject().toString().split(":");
     scen_xml += "\t<czescSwobodna>" +czesc_dowolna[1]+ "</czescSwobodna>\n";
       }
       catch(Exception e)
       {
            scen_xml += "\t<czescSwobodna></czescSwobodna>\n";
       }
     scen_xml += "</opisScenariusza>";
     
     jTextArea3.setText(scen_xml);

        }
        catch (Exception e)
        {
         MessageBox mb = new MessageBox(e.getMessage());
         mb.show();
            
        }
        
    }                                         
        
    }//GEN-LAST:event_jButton11ActionPerformed

    private void odkolorowanie(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_odkolorowanie

        
        // TODO add your handling code here:
        
        jTextField2.setForeground(Color.BLACK);
    }//GEN-LAST:event_odkolorowanie

    private void jTextField4CaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextField4CaretUpdate
        // TODO add your handling code here:
        
        jTextField4.setForeground(Color.BLACK);
    }//GEN-LAST:event_jTextField4CaretUpdate

    private void jTextField1CaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextField1CaretUpdate
        // TODO add your handling code here:
        jTextField1.setForeground(Color.black);
    }//GEN-LAST:event_jTextField1CaretUpdate

    private void jTextField62CaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextField62CaretUpdate
        // TODO add your handling code here:
        
        jTextField62.setForeground(Color.black);
    }//GEN-LAST:event_jTextField62CaretUpdate

    private void jTextField3CaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextField3CaretUpdate
        // TODO add your handling code here:
        jTextField3.setForeground(Color.black);
    }//GEN-LAST:event_jTextField3CaretUpdate

    private void zmien_date(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_zmien_date
        // TODO add your handling code here:

        searchNode_and_Replace(jDateChooser1.getToolTipText(),"Data: " + jDateChooser1.getDate() );
        jDateChooser1.setToolTipText( "Data: " + jDateChooser1.getDate());
    }//GEN-LAST:event_zmien_date

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
        
          
        
        Date date1 = jDateChooser1.getDate();
        date1.setHours(( jComboBox3.getSelectedIndex()+2)%24);
        date1.setMinutes(jComboBox4.getSelectedIndex());
        date1.setSeconds(0);
        jDateChooser1.setDate(date1);
        
        Date date2 = jDateChooser2.getDate();
        date2.setHours( (jComboBox5.getSelectedIndex()+2)%24);
        date2.setMinutes( jComboBox6.getSelectedIndex());
        date2.setSeconds(0);
        jDateChooser2.setDate(date2);
        
  if(date2.before(date1) || date2.equals(date1))
  {
   searchNode_and_Replace(data, "Data: " + jDateChooser1.getDate().toGMTString());// +" - " + jDateChooser2.getDate().toGMTString());
     
                            data = "Data: " + jDateChooser1.getDate().toGMTString();// +" - " + jDateChooser2.getDate().toGMTString();    
  
  }
         else
  {
      searchNode_and_Replace(data, "Data: " + jDateChooser1.getDate().toGMTString() +" - " + jDateChooser2.getDate().toGMTString());
     
                            data = "Data: " + jDateChooser1.getDate().toGMTString() +" - " + jDateChooser2.getDate().toGMTString();
  }
        jButton8.setForeground(Color.decode("#8fc400"));
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jTextField5CaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextField5CaretUpdate
        // TODO add your handling code here:
        jTextField5.setForeground(Color.BLACK);
    }//GEN-LAST:event_jTextField5CaretUpdate

    private void jTextField10CaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextField10CaretUpdate
        // TODO add your handling code here:
        jTextField10.setForeground(Color.BLACK);
    }//GEN-LAST:event_jTextField10CaretUpdate

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        // TODO add your handling code here:
        
        jButton7ActionPerformed(evt);
    }//GEN-LAST:event_jButton12ActionPerformed

      
  public class xml_node_container
  {
      Node node;
      int depth;

        public int getDepth() {
            return depth;
        }
      boolean is_multinode;
      boolean is_just_parrent;
        public void setIs_multinode() {
            this.is_multinode = true;
        }

        public void setIs_just_parrent() {
            this.is_just_parrent = true;
        }
  
      xml_node_container(Node n, int d) 
      {
          node = n;
          depth = d;
          is_multinode = false;
          is_just_parrent = false;
      }
      xml_node_container(Node n, int d, boolean p) 
      {
          node = n;
          depth = d;
          is_multinode = false;
          is_just_parrent = p;
      }
  
  }
    
  JTree jTree2; 
 
  
  public void addChildstoNode(NodeList nl, DefaultMutableTreeNode node, int depth)
  {
      for (int i = 0; i< nl.getLength();i++)
      {
          int temp = 0;
if (nl.item(i).getNodeName() == "#text") continue;
          temp = allNodes.indexOf(new xml_node_container(nl.item(i),depth));
            String tempname = nl.item(i).getNodeName(); 
     if (temp >-1)// && ((xml_node_container)allNodes.get(temp)).node.getParentNode().getNodeName().equals(nl.item(i).getParentNode().getNodeName()) )
  {
      ((xml_node_container)allNodes.get(temp)).is_multinode = true;
      continue;
  }
  String t  = nl.item(i).getNodeName();
          node.add(new DefaultMutableTreeNode(nl.item(i).getNodeName()));
          
         if (ma_dzieci(nl.item(i))) {
              allNodes.add(new xml_node_container(nl.item(i), depth,true));
              
         }
       
     else {
             allNodes.add(new xml_node_container(nl.item(i), depth)); 
      }
          if (ma_dzieci(nl.item(i)))
          {
              Node test = nl.item(i).getFirstChild();
              addChildstoNode(nl.item(i).getChildNodes(),(DefaultMutableTreeNode) node.getLastChild(),depth++);
          }
      }
  }
  

  public boolean ma_dzieci(Node node)
  {
      NodeList nl = node.getChildNodes();
      for (int i = 0;i<nl.getLength();i++)
      {
          short tesme = Node.TEXT_NODE;
          if (nl.item(i).getNodeType() != Node.TEXT_NODE)
          {
              return true;
          }
      }
      return false;
  }
  
  
    public void reload_scan_xml() {
        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
        String xml = "<Opis scenariusza>" + "\n";
        for (int i = 0; i < root.getChildCount(); i++) {

            DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i);
            if (node.getChildCount() > 0) {
                for (int j = 0; j < node.getChildCount(); j++) {
                    DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(j);
                    if (child.getUserObject().toString().contains("autora")) {
                    } else {
                    }
                    
                }
            }
        }
        xml += "</Opis scenariusza>" + "\n";

    }

    
 
    public void searchNode_and_Replace(String nodeStr, String repl) {
        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        DefaultMutableTreeNode m_rootNode = (DefaultMutableTreeNode) model.getRoot();
        DefaultMutableTreeNode node = null;


        Enumeration e = m_rootNode.breadthFirstEnumeration();
        while (e.hasMoreElements()) {
            node = (DefaultMutableTreeNode) e.nextElement();
            if (nodeStr.equals(node.getUserObject().toString())) {
                node.setUserObject(repl);
                model.reload(node);
            }

        }
    }

    public void searchNode_and_add_child(String nodeStr, String newnodename) {


        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        DefaultMutableTreeNode m_rootNode = (DefaultMutableTreeNode) model.getRoot();
        DefaultMutableTreeNode node = null;

        Enumeration e = m_rootNode.breadthFirstEnumeration();
        while (e.hasMoreElements()) {
            node = (DefaultMutableTreeNode) e.nextElement();
            if (nodeStr.equals(node.getUserObject().toString())) {
                node.add(new DefaultMutableTreeNode(newnodename));

                model.reload(node);

            }
        }
    }

    public void searchNode_and_add_child(String nodeStr, DefaultMutableTreeNode newnode) {


        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        DefaultMutableTreeNode m_rootNode = (DefaultMutableTreeNode) model.getRoot();
        DefaultMutableTreeNode node = null;

        Enumeration e = m_rootNode.breadthFirstEnumeration();
        while (e.hasMoreElements()) {
            node = (DefaultMutableTreeNode) e.nextElement();
            if (nodeStr.equals(node.getUserObject().toString())) {
                node.add(newnode);

                model.reload(node);

            }
        }
    }
    
        public void searchNode_and_insert_child(String nodeStr, DefaultMutableTreeNode newnode,int pos) {


        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        DefaultMutableTreeNode m_rootNode = (DefaultMutableTreeNode) model.getRoot();
        DefaultMutableTreeNode node = null;

        Enumeration e = m_rootNode.breadthFirstEnumeration();
        while (e.hasMoreElements()) {
            node = (DefaultMutableTreeNode) e.nextElement();
            if (nodeStr.equals(node.getUserObject().toString())) {
                node.insert(newnode, pos);

                model.reload(node);

            }
        }
    }
        
           public void searchNode_and_insert_child_after(String nodeStr,String afterNode, String newnode ) {


        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        DefaultMutableTreeNode m_rootNode = (DefaultMutableTreeNode) model.getRoot();
        DefaultMutableTreeNode node = null;
int pos = -1;
        Enumeration e = m_rootNode.breadthFirstEnumeration();
        while (e.hasMoreElements()) {
            node = (DefaultMutableTreeNode) e.nextElement();
            if (nodeStr.equals(node.getUserObject().toString())) {
                
                for (int i = 0; i< node.getChildCount();i++)
                {
                    DefaultMutableTreeNode temp = (DefaultMutableTreeNode) node.getChildAt(i);
                    String chuj = temp.getUserObject().toString();
                    if (temp.getUserObject().toString() == afterNode){     
                     pos = i;
                    }
                }
                node.insert(new DefaultMutableTreeNode(newnode),pos);

            }
        }
           }
    
             public int searchNode_and_return_pos(String nodeStr, String chiid) {

                  DefaultMutableTreeNode node2 = new DefaultMutableTreeNode(chiid);

        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        DefaultMutableTreeNode m_rootNode = (DefaultMutableTreeNode) model.getRoot();
        DefaultMutableTreeNode node = null;

        Enumeration e = m_rootNode.breadthFirstEnumeration();
        while (e.hasMoreElements()) {
            node = (DefaultMutableTreeNode) e.nextElement();
            if (nodeStr.equals(node.getUserObject().toString())) {
                
                return node.getIndex(node2);

            }
        }
        return -1;
    }
        
    public void searchNode_and_add_grandchild(String nodeStr, String grand_name, int childidx) {


        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        DefaultMutableTreeNode m_rootNode = (DefaultMutableTreeNode) model.getRoot();
        DefaultMutableTreeNode node = null;

        Enumeration e = m_rootNode.breadthFirstEnumeration();
        while (e.hasMoreElements()) {
            node = (DefaultMutableTreeNode) e.nextElement();
            if (nodeStr.equals(node.getUserObject().toString())) {

                DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(childidx);


                child.add(new DefaultMutableTreeNode(grand_name));


                model.reload(node);

            }
        }
    }
    
    
        public void searchNode_and_replace_child(String nodeStr,int idx, String newnodename) {


        DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel();
        DefaultMutableTreeNode m_rootNode = (DefaultMutableTreeNode) model.getRoot();
        DefaultMutableTreeNode node = null;
DefaultMutableTreeNode node2 = null;
        Enumeration e = m_rootNode.breadthFirstEnumeration();
        while (e.hasMoreElements()) {
            node = (DefaultMutableTreeNode) e.nextElement();
            if (nodeStr.equals(node.getUserObject().toString())) {
                node2 = (DefaultMutableTreeNode)node.getChildAt(idx);
                node2.setUserObject(newnodename);
                model.reload(node);

            }
        }
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton34;
    private javax.swing.JButton jButton35;
    private javax.swing.JButton jButton36;
    private javax.swing.JButton jButton37;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JComboBox jComboBox6;
    private com.toedter.calendar.JDateChooser jDateChooser1;
    private com.toedter.calendar.JDateChooser jDateChooser2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel66;
    private javax.swing.JLabel jLabel67;
    private javax.swing.JLabel jLabel68;
    private javax.swing.JLabel jLabel69;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField59;
    private javax.swing.JTextField jTextField60;
    private javax.swing.JTextField jTextField61;
    private javax.swing.JTextField jTextField62;
    private javax.swing.JTree jTree1;
    // End of variables declaration//GEN-END:variables
}
